--[[/**
-- * 
 * [0] 损失最大生命值
 * [1] 最高不超过
 * [2] 回血
-- *
-- */]]

---@class BuffEffect492101 : BaseBuffEffect
BuffEffect492101 = ClientFight.CreateClass("BuffEffect492101", ClientFight.BaseBuffEffect)
local t = BuffEffect492101

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
   local parameters = {...};
    if (table.getn(parameters) < 1)then
    return IBuffEffect.FAIL;
    end

    local buffEffectValue = buff.buffBean.f_BuffEffectValue;
    local target = buff.target;
    local maxHp = FighterAttributeManager.getFightAttr(target, FighterAttributeEnum.HP);
    local damage = Utils.calcRatio(maxHp, buffEffectValue[1]);
    local maxLimit = Utils.calcRatio(FighterAttributeManager.getFightAttr(buff.source, FighterAttributeEnum.ATK), buffEffectValue[2]);
    if (damage > maxLimit) then
    damage = maxLimit;
    end
    local addHp = Utils.calcRatio(damage, buffEffectValue[3]);
    local logDamage = damage;
    DamageManager.setFighterHp(fight, target, buff.source, null, DamageResultTypeEnum.NORMAL,-damage,target.hp - damage,true,true,false);
    DamageManager.setFighterHp(fight, buff.source, buff.source, buff.skill, DamageResultTypeEnum.HEAL,addHp,buff.source.hp +addHp,true,false, true);
    SkillRoleMgr.savePathFile( "[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff"
    .. buff.modelId .. " 触发流血, 伤害: " .. logDamage .. "  "..buff.source.fighterId.." 回血: " .. addHp);

    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()